package com.scau.service.impl;

import com.scau.dao.WishListMapper;
import com.scau.pojo.WishListExample;
import com.scau.pojo.WishListKey;
import com.scau.service.IWishListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WishListServiceImpl implements IWishListService {

    @Autowired
    WishListMapper wishListMapper;

    @Override
    public List<WishListKey> selectByUserName(String userName) {
        WishListExample example = new WishListExample();
        example.createCriteria().andUsernameEqualTo(userName);
        List<WishListKey> wishListKeys = wishListMapper.selectByExample(example);
        return wishListKeys ;
    }

    @Override
    public void deleteWishListItem(String userName, String goodsId) {
        WishListExample wishListExample = new WishListExample();
        wishListExample.createCriteria().andUsernameEqualTo(userName).andGoodIdEqualTo(goodsId);
        wishListMapper.deleteByExample(wishListExample);
    }

    @Override
    public int addWishList(WishListKey wishListKey) {
        return wishListMapper.insert(wishListKey);

    }
}
